package com.songshuai.webapi.baseapi.enumerations.crm.error;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public enum ClueImportError {

    ERROR_PHONE_FORMAT(1,"手机号格式不正确"),
    ERROR_PHONE_IS_EXIST(2,"手机号在线索信息表已经存在"),
    ERROR_PHONE_REPEAT(3,"手机号在Excel中存在重复"),
    ERROR_DATE_FORMAT(4,"日期格式化时出错"),
    ERROR_VALIDATE_NULL_ROW(5,"校验空行时出错");

    private int code;
    private String msg;

    ClueImportError(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    @SneakyThrows(IllegalArgumentException.class)
    public static int getCode(String define){
        return ClueImportError.valueOf(define).code;
    }

    @SneakyThrows(IllegalArgumentException.class)
    public static String getMsg(String define){
        return ClueImportError.valueOf(define).msg;
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(ClueImportError err : ClueImportError.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
